package com.bdqn.biz;

import com.bdqn.dao.BaseDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "NewADD", value = "/NewADD")
public class NewADD extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post 方法");
        request.setCharacterEncoding("utf-8");
        String nn=request.getParameter("nn");
        String s1=request.getParameter("s1");
        //调用底层basedao 修改数据库
        try {
            BaseDao.update("insert into newtable(title,ntype)values(?,?)",
                    new Object[]{nn,s1}
            );
            //跳转到页面上
            response.sendRedirect("/Web1/List.jsp?index=1");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
